def sum_2(a,b): # 形参
    # a = 1
    # b = 2
    # print(a)
    # print(b)
    return a + b


result = sum_2(9,8) # 实参
a = len('get')
print(a)
print(result)

def power(x,n=2): # n:默认参数，缺省参数
    return x ** n
a = power(4,3)
print(a)
b = power(5,3)
print(b)
c = power(6)
print(c)
a= int('16',8)
print(a)

def infos(name,age=24,gender='女'):
    return '大家好，我叫%s，我今年%d岁，我是一名%s生' % (name,age,gender)
s = infos('mia',24,'女')
lily = infos('lily',25)
print(lily)
print(s)
jack = infos('jack',gender='男')
print(jack)

# 可变参数

def total(*args): # 可变参数
    print(args) # (1,4,5,6,7,8,3) 打包成元组
    result = 0
    for i in args:
        result += i
    return result
result = total(1,4,5,6,7,8,3)
print(result)

result = total(3,4,5)
print(result)

a = [1,2,4]
result = total(*a)
print(result)

def f(**kwargs): # 可变参数，接收字典
    for k,v in kwargs.items():
        print(k,v)

d = {
    'name':'小明',
    'age':18,
}
f(**d)



